Change the order of the update func to make it more compatible with the
authorJonathan Blandford <jrb@redhat.com>
Wed, 5 Jan 2000 23:06:13 +0000 (23:06 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Wed, 5 Jan 2000 23:06:13 +0000 (23:06 +0000)
2000-01-05  Jonathan Blandford  <jrb@redhat.com>

* gdk-pixbuf/gdk-pixbuf-io.h: Change the order of the update func
to make it more compatible with the rest of GTK.  Added animation
framework for progressive loading.

* gdk-pixbuf/io-bmp.c (image_begin_load): Modified to handle new
system.
* gdk-pixbuf/io-ico.c (image_begin_load): ditto
* gdk-pixbuf/io-png.c (image_begin_load): ditto
* gdk-pixbuf/io-ras.c (image_begin_load): ditto
* gdk-pixbuf/io-jpeg.c (image_begin_load): ditto
* gdk-pixbuf/io-pnm.c (image_begin_load): ditto
* gdk-pixbuf/io-tiff.c (image_begin_load): ditto
* gdk-pixbuf/io-gif.c (image_begin_load): ditto

12 files changed:
gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.h
gdk-pixbuf/gdk-pixbuf-loader.c
gdk-pixbuf/io-bmp.c
gdk-pixbuf/io-gif.c
gdk-pixbuf/io-ico.c
gdk-pixbuf/io-jpeg.c
gdk-pixbuf/io-png.c
gdk-pixbuf/io-pnm.c
gdk-pixbuf/io-ras.c
gdk-pixbuf/io-tiff.c
gtk/gdk-pixbuf-loader.c

index 0e92c68a79fa83c9dbc745989cdbc57223604d75..6a109b6bfd80e5be1782918ab832507b3b4fd70a 100644 (file)
@@ -1,3 +1,19 @@
+2000-01-05  Jonathan Blandford  <jrb@redhat.com>
+
+       * gdk-pixbuf/gdk-pixbuf-io.h: Change the order of the update func
+       to make it more compatible with the rest of GTK.  Added animation
+       framework for progressive loading.
+       * gdk-pixbuf/io-bmp.c (image_begin_load): Modified to handle new
+       system.  
+       * gdk-pixbuf/io-ico.c (image_begin_load): ditto
+       * gdk-pixbuf/io-png.c (image_begin_load): ditto
+       * gdk-pixbuf/io-ras.c (image_begin_load): ditto
+       * gdk-pixbuf/io-jpeg.c (image_begin_load): ditto
+       * gdk-pixbuf/io-pnm.c (image_begin_load): ditto
+       * gdk-pixbuf/io-tiff.c (image_begin_load): ditto
+       * gdk-pixbuf/io-gif.c (image_begin_load): ditto
+
 2000-01-05  Owen Taylor  <otaylor@redhat.com>
 
        * gdk-pixbuf/pixops/README: Added a README with a TODO
index 966768f1a5fdff5fd29785d6468bf5c6017c7928..e6ba541c02476c173fe49631009f5bcdb83dcfa8 100644 (file)
@@ -1,4 +1,5 @@
-/* GdkPixbuf library - Io handling
+/* GdkPixbuf library - Io handling.  This is an internal header for gdk-pixbuf.
+ * You should never use it unless you are doing developement for gdkpixbuf itself.
  *
  * Copyright (C) 1999 The Free Software Foundation
  *
@@ -38,9 +39,16 @@ extern "C" {
 \f
 
 typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
-typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data,
+typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf,
                                          guint x, guint y,
-                                         guint width, guint height);
+                                         guint width, guint height,
+                                         gpointer user_data);
+/* Needed only for animated images. */
+typedef void (* ModuleFrameDoneNotifyFunc) (GdkPixbuf *pixbuf,
+                                           gint frame,
+                                           gpointer user_data);
+typedef void (* ModuleAnimationDoneNotifyFunc) (GdkPixbuf *pixbuf,
+                                               gpointer user_data);
 
 typedef struct _GdkPixbufModule GdkPixbufModule;
 struct _GdkPixbufModule {
@@ -54,6 +62,8 @@ struct _GdkPixbufModule {
 
         gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
                                 ModuleUpdatedNotifyFunc update_func,
+                                ModuleFrameDoneNotifyFunc frame_done_func,
+                                ModuleAnimationDoneNotifyFunc anim_done_func,
                                 gpointer user_data);
         void (* stop_load) (gpointer context);
         gboolean (* load_increment) (gpointer context, const guchar *buf, guint size);
index 3d2243662a0f328060d05baea583e57a6d7b37e8..cd1b91418b16549104a6de0c0f2a8bc96a613c45 100644 (file)
@@ -222,7 +222,7 @@ gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf, gpointer loader)
 }
 
 static void
-gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
+gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, guint x, guint y, guint width, guint height, gpointer loader)
 {
        GdkPixbufLoaderPrivate *priv = NULL;
 
@@ -276,7 +276,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
                return 0;
        }
 
-       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
+       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, NULL, NULL, loader);
 
        if (priv->context == NULL) {
                g_warning("Failed to begin progressive load");
index ebce8d7b75af4b117d7ca27beade82a845ba4276..65d65f1be3eca1f87e0da05401330000c5384ee7 100644 (file)
@@ -173,7 +173,10 @@ struct bmp_progressive_state {
 
 gpointer
 image_begin_load(ModulePreparedNotifyFunc prepared_func,
-                ModuleUpdatedNotifyFunc updated_func, gpointer user_data);
+                ModuleUpdatedNotifyFunc updated_func,
+                ModuleFrameDoneNotifyFunc frame_done_func,
+                ModuleAnimationDoneNotifyFunc anim_done_func,
+                gpointer user_data);
 void image_stop_load(gpointer data);
 gboolean image_load_increment(gpointer data, guchar * buf, guint size);
 
@@ -189,7 +192,7 @@ GdkPixbuf *image_load(FILE * f)
 
        GdkPixbuf *pb;
 
-       State = image_begin_load(NULL, NULL, NULL);
+       State = image_begin_load(NULL, NULL, NULL, NULL, NULL);
        membuf = g_malloc(4096);
 
        g_assert(membuf != NULL);
@@ -303,7 +306,10 @@ static void DecodeHeader(unsigned char *BFH, unsigned char *BIH,
 
 gpointer
 image_begin_load(ModulePreparedNotifyFunc prepared_func,
-                ModuleUpdatedNotifyFunc updated_func, gpointer user_data)
+                ModuleUpdatedNotifyFunc updated_func,
+                ModuleFrameDoneNotifyFunc frame_done_func,
+                ModuleAnimationDoneNotifyFunc anim_done_func,
+                gpointer user_data)
 {
        struct bmp_progressive_state *context;
 
@@ -529,11 +535,11 @@ static void OneLine(struct bmp_progressive_state *context)
 
        if (context->updated_func != NULL) {
                (*context->updated_func) (context->pixbuf,
-                                         context->user_data,
                                          0,
                                          context->Lines,
                                          context->Header.width,
-                                         context->Header.height);
+                                         context->Header.height,
+                                         context->user_data);
 
        }
 }
index 467df06824eb2164c637e884a534886ba58d0137..13a66cfba4769e3a9775385e416e0006ef0f4160 100644 (file)
@@ -786,31 +786,31 @@ gif_get_lzw (GifContext *context)
                if (lower_bound <= upper_bound && first_pass == context->draw_pass) {
                        (* context->update_func)
                                (context->pixbuf,
-                                context->user_data,
                                 0, lower_bound,
                                 gdk_pixbuf_get_width (context->pixbuf),
-                                upper_bound - lower_bound);
+                                upper_bound - lower_bound,
+                                context->user_data);
                } else {
                        if (lower_bound <= upper_bound) {
                                (* context->update_func)
                                        (context->pixbuf,
-                                        context->user_data,
                                         0, 0,
                                         gdk_pixbuf_get_width (context->pixbuf),
-                                        gdk_pixbuf_get_height (context->pixbuf));
+                                        gdk_pixbuf_get_height (context->pixbuf),
+                                        context->user_data);
                        } else {
                                (* context->update_func)
                                        (context->pixbuf,
-                                        context->user_data,
                                         0, 0,
                                         gdk_pixbuf_get_width (context->pixbuf),
-                                        upper_bound);
+                                        upper_bound,
+                                        context->user_data);
                                (* context->update_func)
                                        (context->pixbuf,
-                                        context->user_data,
                                         0, lower_bound,
                                         gdk_pixbuf_get_width (context->pixbuf),
-                                        gdk_pixbuf_get_height (context->pixbuf));
+                                        gdk_pixbuf_get_height (context->pixbuf),
+                                        context->user_data);
                        }
                }
        }
@@ -1087,6 +1087,8 @@ image_load (FILE *file)
 gpointer
 image_begin_load (ModulePreparedNotifyFunc prepare_func,
                  ModuleUpdatedNotifyFunc update_func,
+                 ModuleFrameDoneNotifyFunc frame_done_func,
+                 ModuleAnimationDoneNotifyFunc anim_done_func,
                  gpointer user_data)
 {
        GifContext *context;
index 052c74a9c8d57d76c5eb8aa4e22930c2b9e53f09..22d1769ee7bbdc31c25ddbbd6ab9368620e61e90 100644 (file)
@@ -154,7 +154,10 @@ struct ico_progressive_state {
 
 gpointer
 image_begin_load(ModulePreparedNotifyFunc prepared_func,
-                ModuleUpdatedNotifyFunc updated_func, gpointer user_data);
+                ModuleUpdatedNotifyFunc updated_func,
+                ModuleFrameDoneNotifyFunc frame_done_func,
+                ModuleAnimationDoneNotifyFunc anim_done_func,
+                gpointer user_data);
 void image_stop_load(gpointer data);
 gboolean image_load_increment(gpointer data, guchar * buf, guint size);
 
@@ -170,7 +173,7 @@ GdkPixbuf *image_load(FILE * f)
 
        GdkPixbuf *pb;
 
-       State = image_begin_load(NULL, NULL, NULL);
+       State = image_begin_load(NULL, NULL, NULL, NULL, NULL);
        membuf = g_malloc(4096);
 
        g_assert(membuf != NULL);
@@ -363,7 +366,10 @@ static void DecodeHeader(guchar *Data, gint Bytes,
 
 gpointer
 image_begin_load(ModulePreparedNotifyFunc prepared_func,
-                ModuleUpdatedNotifyFunc updated_func, gpointer user_data)
+                ModuleUpdatedNotifyFunc updated_func,
+                ModuleFrameDoneNotifyFunc frame_done_func,
+                ModuleAnimationDoneNotifyFunc anim_done_func,
+                gpointer user_data)
 {
        struct ico_progressive_state *context;
 
@@ -609,11 +615,11 @@ static void OneLine(struct ico_progressive_state *context)
 
        if (context->updated_func != NULL) {
                (*context->updated_func) (context->pixbuf,
-                                         context->user_data,
                                          0,
                                          context->Lines,
                                          context->Header.width,
-                                         context->Header.height);
+                                         context->Header.height,
+                                         context->user_data);
 
        }
 }
index 68660d4c74f9ac9ff8040fbaee1c9b328574ed68..4cea124e0908614618ffe1713befdcec68a53d6c 100644 (file)
@@ -89,7 +89,10 @@ typedef struct {
 
 GdkPixbuf *image_load (FILE *f);
 gpointer image_begin_load (ModulePreparedNotifyFunc func, 
-                          ModuleUpdatedNotifyFunc func2, gpointer user_data);
+                          ModuleUpdatedNotifyFunc func2,
+                          ModuleFrameDoneNotifyFunc func3,
+                          ModuleAnimationDoneNotifyFunc func4,
+                          gpointer user_data);
 void image_stop_load (gpointer context);
 gboolean image_load_increment(gpointer context, guchar *buf, guint size);
 
@@ -274,6 +277,8 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
 gpointer
 image_begin_load (ModulePreparedNotifyFunc prepared_func, 
                  ModuleUpdatedNotifyFunc  updated_func,
+                 ModuleFrameDoneNotifyFunc frame_func,
+                 ModuleAnimationDoneNotifyFunc anim_done_func,
                  gpointer user_data)
 {
        JpegProgContext *context;
@@ -508,11 +513,11 @@ image_load_increment (gpointer data, guchar *buf, guint size)
 
                                /* send updated signal */
                                (* context->updated_func) (context->pixbuf,
-                                                context->user_data,
-                                                0, 
-                                                cinfo->output_scanline-1,
-                                                cinfo->image_width, 
-                                                nlines);
+                                                          0, 
+                                                          cinfo->output_scanline-1,
+                                                          cinfo->image_width, 
+                                                          nlines,
+                                                          context->user_data);
 
 #undef DEBUG_JPEG_PROGRESSIVE
 #ifdef DEBUG_JPEG_PROGRESSIVE
index 75e456144af4c9dd56b23c76947c3cf19a5cd24b..84a2a0acb6ac6f1f9a07f9ca5211f35bb0a2e583 100644 (file)
@@ -276,6 +276,8 @@ struct _LoadContext {
 gpointer
 image_begin_load (ModulePreparedNotifyFunc prepare_func,
                  ModuleUpdatedNotifyFunc update_func,
+                 ModuleFrameDoneNotifyFunc frame_done_func,
+                 ModuleAnimationDoneNotifyFunc anim_done_func,
                  gpointer user_data)
 {
         LoadContext* lc;
@@ -367,34 +369,38 @@ image_load_increment(gpointer context, guchar *buf, guint size)
                         
                         if (pass_diff == 0) {
                                 /* start and end row were in the same pass */
-                                (lc->update_func)(lc->pixbuf, lc->notify_user_data, 0,
+                                (lc->update_func)(lc->pixbuf, 0,
                                                   lc->first_row_seen_in_chunk,
                                                   lc->pixbuf->art_pixbuf->width,
                                                   (lc->last_row_seen_in_chunk -
-                                                   lc->first_row_seen_in_chunk) + 1);
+                                                   lc->first_row_seen_in_chunk) + 1,
+                                                 lc->notify_user_data);
                         } else if (pass_diff == 1) {
                                 /* We have from the first row seen to
                                    the end of the image (max row
                                    seen), then from the top of the
                                    image to the last row seen */
                                 /* first row to end */
-                                (lc->update_func)(lc->pixbuf, lc->notify_user_data, 0,
+                                (lc->update_func)(lc->pixbuf, 0,
                                                   lc->first_row_seen_in_chunk,
                                                   lc->pixbuf->art_pixbuf->width,
                                                   (lc->max_row_seen_in_chunk -
-                                                   lc->first_row_seen_in_chunk) + 1);
+                                                   lc->first_row_seen_in_chunk) + 1,
+                                                 lc->notify_user_data);
                                 /* top to last row */
-                                (lc->update_func)(lc->pixbuf, lc->notify_user_data,
+                                (lc->update_func)(lc->pixbuf,
                                                   0, 0, 
                                                   lc->pixbuf->art_pixbuf->width,
-                                                  lc->last_row_seen_in_chunk + 1);
+                                                  lc->last_row_seen_in_chunk + 1,
+                                                 lc->notify_user_data);
                         } else {
                                 /* We made at least one entire pass, so update the
                                    whole image */
-                                (lc->update_func)(lc->pixbuf, lc->notify_user_data,
+                                (lc->update_func)(lc->pixbuf,
                                                   0, 0, 
                                                   lc->pixbuf->art_pixbuf->width,
-                                                  lc->max_row_seen_in_chunk + 1);
+                                                  lc->max_row_seen_in_chunk + 1,
+                                                 lc->notify_user_data);
                         }
                 }
                 
index e1cdd5f5d6b64fff63b7153bb81d7b5db4833095..6d61db91b71742e86178ac0ba0755ecf220772b9 100644 (file)
@@ -77,7 +77,10 @@ typedef struct {
 
 GdkPixbuf *image_load (FILE *f);
 gpointer image_begin_load (ModulePreparedNotifyFunc func, 
-                          ModuleUpdatedNotifyFunc func2, gpointer user_data);
+                          ModuleUpdatedNotifyFunc func2,
+                          ModuleFrameDoneNotifyFunc frame_done_func,
+                          ModuleAnimationDoneNotifyFunc anim_done_func,
+                          gpointer user_data);
 void image_stop_load (gpointer context);
 gboolean image_load_increment(gpointer context, guchar *buf, guint size);
 
@@ -686,6 +689,8 @@ image_load (FILE *f)
 gpointer
 image_begin_load (ModulePreparedNotifyFunc prepared_func, 
                  ModuleUpdatedNotifyFunc  updated_func,
+                 ModuleFrameDoneNotifyFunc frame_done_func,
+                 ModuleAnimationDoneNotifyFunc anim_done_func,
                  gpointer user_data)
 {
        PnmLoaderContext *context;
@@ -836,11 +841,11 @@ image_load_increment (gpointer data, guchar *buf, guint size)
 
                                /* send updated signal */
                                (* context->updated_func) (context->pixbuf,
-                                                context->user_data,
-                                                0, 
-                                                context->output_row-1,
-                                                context->width, 
-                                                1);
+                                                          0, 
+                                                          context->output_row-1,
+                                                          context->width, 
+                                                          1,
+                                                          context->user_data);
                        }
                }
 
index e0b2e4158311b90e2c012f76c039087b212eb26c..17a45942d44c4d5aa533d8e56a53d5cd3e3e8e8d 100644 (file)
@@ -94,7 +94,10 @@ struct ras_progressive_state {
 
 gpointer
 image_begin_load(ModulePreparedNotifyFunc prepared_func,
-                ModuleUpdatedNotifyFunc updated_func, gpointer user_data);
+                ModuleUpdatedNotifyFunc updated_func,
+                ModuleFrameDoneNotifyFunc frame_done_func,
+                ModuleAnimationDoneNotifyFunc anim_done_func,
+                gpointer user_data);
 void image_stop_load(gpointer data);
 gboolean image_load_increment(gpointer data, guchar * buf, guint size);
 
@@ -109,7 +112,7 @@ GdkPixbuf *image_load(FILE * f)
        
        GdkPixbuf *pb;
        
-       State = image_begin_load(NULL, NULL, NULL);
+       State = image_begin_load(NULL, NULL, NULL, NULL, NULL);
        
        membuf = g_malloc(4096);
        
@@ -206,7 +209,10 @@ static void RAS2State(struct rasterfile *RAS,
 
 gpointer
 image_begin_load(ModulePreparedNotifyFunc prepared_func,
-                ModuleUpdatedNotifyFunc updated_func, gpointer user_data)
+                ModuleUpdatedNotifyFunc updated_func,
+                ModuleFrameDoneNotifyFunc frame_done_func,
+                ModuleAnimationDoneNotifyFunc anim_done_func,
+                gpointer user_data)
 {
        struct ras_progressive_state *context;
 
@@ -364,11 +370,11 @@ static void OneLine(struct ras_progressive_state *context)
 
        if (context->updated_func != NULL) {
                (*context->updated_func) (context->pixbuf,
-                                         context->user_data,
                                          0,
                                          context->Lines,
                                          context->Header.width,
-                                         context->Header.height);
+                                         context->Header.height,
+                                         context->user_data);
 
        }
 }
index 208a1b724b51725152aeaea27912c0e6aa29df16..155a035778c50d57b99112d0e3d5f2987f6ebda4 100644 (file)
@@ -111,7 +111,7 @@ image_load_real (FILE *f, TiffData *context)
 
        if (context) {
                gdk_pixbuf_unref (pixbuf);
-               (* context->update_func) (pixbuf, context->user_data, 0, 0, w, h);
+               (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data);
        }
 
        return pixbuf;
@@ -139,6 +139,8 @@ image_load (FILE *f)
 gpointer
 image_begin_load (ModulePreparedNotifyFunc prepare_func,
                  ModuleUpdatedNotifyFunc update_func,
+                 ModuleFrameDoneNotifyFunc frame_done_func,
+                 ModuleAnimationDoneNotifyFunc anim_done_func,
                  gpointer user_data)
 {
        TiffData *context;
index 3d2243662a0f328060d05baea583e57a6d7b37e8..cd1b91418b16549104a6de0c0f2a8bc96a613c45 100644 (file)
@@ -222,7 +222,7 @@ gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf, gpointer loader)
 }
 
 static void
-gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
+gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, guint x, guint y, guint width, guint height, gpointer loader)
 {
        GdkPixbufLoaderPrivate *priv = NULL;
 
@@ -276,7 +276,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
                return 0;
        }
 
-       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
+       priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, NULL, NULL, loader);
 
        if (priv->context == NULL) {
                g_warning("Failed to begin progressive load");